package net.openl10n.mdf;

import java.util.Set;


abstract class AbstractDocumentPartBuilder{
	
	protected Long version;
	protected PartId id;

	AbstractDocumentPartBuilder(){
	}
	
	AbstractDocumentPartBuilder(AbstractDocumentPart documentPart){
		this.id = documentPart.getId();
		this.version = documentPart.getVersion();
	}

	public PartId getId() {
		return id;
	}
	
	public void setId(PartId id) {
		this.id = id;
	}
	
	public Long getVersion() {
		return version;
	}
	
	public void setVersion(Long version) {
		this.version = version;
	}
	
	
	boolean isValid(){
		return version != null && id != null; 
	}
	
	void populateInvalidFields(Set<String> invalidFields){
		if(version == null){
			invalidFields.add("version");
		}
		if(id == null){
			invalidFields.add("id");
		}
	}
	
}
